! function(window, document) {
    let regBtn = document.querySelector("#regBtn");
    regBtn.onclick = async function() {
        let name = document.querySelector("#name").value;
        let password = document.querySelector("#password").value;
        let email = document.querySelector("#email").value;
        let imgPath = document.querySelector("img").src;


        let params = {
            name,
            password,
            email,
            imgPath
        }
        let regResult = await ajax({ type: "post", url: "/register", params })
        if (regResult.success) {
            location.href = "/login"
        } else {
            alert(regResult.data)
        }

    }

    document.querySelector("#picFile").onchange = function() {
        document.querySelector("form").submit()
    }

    document.querySelector("iframe").onload = function() {
        let selfWindow = this.contentWindow;
        let resultObj = JSON.parse(selfWindow.document.body.innerHTML);
        document.querySelector("img").src = resultObj.path;
    }



}(window, document)